#!/bin/bash
rootpasswd="raspberry"
defaultpasswd="raspberry"
echo "$defaultpasswd" | sudo -S apt update -y
echo "$defaultpasswd" | sudo -S apt install expect -y
echo "now we  make root password $rootpasswd"
/usr/bin/expect <<-EOF
set timeout 30
spawn sudo passwd root
expect {
"*$USER*" { send "$defaultpasswd\r"; exp_continue }
"New*" { send "$rootpasswd\r"; exp_continue }
"Retype*" { send "$rootpasswd\r" }
}
EOF
cv2_package=(libhdf5-dev libatlas-base-dev libjasper-dev libqt4-test libqtgui4 vim network-manager)
echo "$defaultpasswd" | sudo -S sed -i.bak '32cPermitRootLogin yes' /etc/ssh/sshd_config
echo "$defaultpasswd" | sudo -S /etc/init.d/ssh restart
echo "$defaultpasswd" | sudo -S cp ./sources.list /etc/apt/sources.list
echo "$defaultpasswd" | sudo -S cp ./raspi.list /etc/apt/sources.list.d/raspi.list
echo "$defaultpasswd" | sudo -S apt update -y
echo "$defaultpasswd" | sudo -S apt upgrade -y
echo "$defaultpasswd" | sudo -S apt install ${cv2_package[@]} -y
echo "$defaultpasswd" | sudo -S apt remove python3-numpy python-numpy -y
pip3 install opencv-contrib-python -i http://pypi.douban.com/simple/
echo "$defaultpasswd" | sudo -S raspi-config nonint do_vnc 0
echo "$defaultpasswd" | sudo -S raspi-config nonint do_camera 0
echo "$defaultpasswd" | sudo -S apt autoremove -y
